From 714dd0cab06df74fb47c4b379df332fb0d2ff0de Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.com>
Date: Tue, 8 Nov 2022 14:40:52 +0000
Subject: [PATCH] overlays: Extend audremap to supports other pins

Add the parameters pins_40_41 and pins_40_45 to support other audio pin
options. Also, simplify the overlay using literal assignments.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
 arch/arm/boot/dts/overlays/README             |  6 ++--
 .../boot/dts/overlays/audremap-overlay.dts    | 29 ++++++-------------
 2 files changed, 13 insertions(+), 22 deletions(-)

--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -680,10 +680,12 @@ Info:   Switches PWM sound output to GPI
 Load:   dtoverlay=audremap,<param>=<val>
 Params: swap_lr                 Reverse the channel allocation, which will also
                                 swap the audio jack outputs (default off)
-        enable_jack             Don't switch off the audio jack output
-                                (default off)
+        enable_jack             Don't switch off the audio jack output. Does
+                                nothing on BCM2711 (default off)
         pins_12_13              Select GPIOs 12 & 13 (default)
         pins_18_19              Select GPIOs 18 & 19
+        pins_40_41              Select GPIOs 40 & 41
+        pins_40_45              Select GPIOs 40 & 45
 
 
 Name:   balena-fin
--- a/arch/arm/boot/dts/overlays/audremap-overlay.dts
+++ b/arch/arm/boot/dts/overlays/audremap-overlay.dts
@@ -7,28 +7,11 @@
         fragment@0 {
                 target = <&audio_pins>;
                 frag0: __overlay__ {
+                        brcm,pins = <12 13>;
                 };
         };
 
 	fragment@1 {
-                target = <&audio_pins>;
-                __overlay__ {
-                        brcm,pins = < 12 13 >;
-                        brcm,function = < 4 >; /* alt0 alt0 */
-                        brcm,pull = < 0 >;
-                };
-        };
-
-	fragment@2 {
-		target = <&audio_pins>;
-		__dormant__ {
-                        brcm,pins = < 18 19 >;
-                        brcm,function = < 2 >; /* alt5 alt5 */
-                        brcm,pull = < 0 >;
-		};
-	};
-
-	fragment@3 {
 		target = <&chosen>;
 		__overlay__  {
 			bootargs = "snd_bcm2835.enable_headphones=1";
@@ -38,7 +21,13 @@
 	__overrides__ {
 		swap_lr = <&frag0>, "swap_lr?";
 		enable_jack = <&frag0>, "enable_jack?";
-		pins_12_13 = <0>,"+1-2";
-		pins_18_19 = <0>,"-1+2";
+		pins_12_13 = <&frag0>,"brcm,pins:0=12",
+		             <&frag0>,"brcm,pins:4=13";
+		pins_18_19 = <&frag0>,"brcm,pins:0=18",
+		             <&frag0>,"brcm,pins:4=19";
+		pins_40_41 = <&frag0>,"brcm,pins:0=40",
+		             <&frag0>,"brcm,pins:4=41";
+		pins_40_45 = <&frag0>,"brcm,pins:0=40",
+		             <&frag0>,"brcm,pins:4=45";
 	};
 };
